#include "contentaction_handler.h"

#include <QtDeclarative/qdeclarative.h>

#include <QtCore/QDebug>
#include <contentaction.h>

ContentActionHandler::ContentActionHandler(QDeclarativeItem *parent):
        QDeclarativeItem(parent)
{
    // By default, QDeclarativeItem does not draw anything. If you subclass
    // QDeclarativeItem to create a visual item, you will need to uncomment the
    // following line:

    // setFlag(ItemHasNoContents, false);
}

ContentActionHandler::~ContentActionHandler()
{
}

void ContentActionHandler::triggerDesktopEntry(const QString &desktopEntry)
{
    ContentAction::Action action = ContentAction::Action::defaultActionForFile(desktopEntry, "application/x-desktop");
    if (action.isValid())
        action.trigger();
    else
        qDebug() << "Action for " << desktopEntry << " is not valid";
}
